<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const arr1 = [1, 2, 3, 4, 5]
        // function myfilter() {

        // }

        Array.prototype.myfilter = function (arr1, fn) {
            for (var i = 0; i < arr1.length; i++) {
                fn(arr1[i])
            }
        }
        // arr.myfilter()

        arr1.myfilter(arr1, function (i) {
            console.log(i);
            if(i>3)
        })

        // arr.filter(item => {
        //     return item > 3
        // })
    </script>
</body>

</html>